package com.ojoin.ojoin.eb_spider.service.stat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.ojoin.ojoin.eb_spider.utils.WebServiceUtils;
import com.ojoin.trade.common.utils.LogUtils;
import com.ojoin.trade.common.utils.TimeUtils;
import com.ojoin.trade.supplyloan_core.web.domain.TbCatchdataStrategy;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlLoanStatTotal;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlPlatformUser;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlSupplyInventory;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlSupplyPayment;
@Service
public class PrepaymentSUNINGstat  extends BaseStatTotal{

	private Logger log = LoggerFactory.getLogger(PrepaymentSUNINGstat.class);
	
	/**
	 * 统计方法：抵押物总额（未标记库存单据金额）*折扣-利息
	 * 
	 * 标准方法，抵押物总额（最近一次结款日之后入库金额）-负债-利息
	 * 
	 * 策略：抵押物总额（未标记库存单据金额  + 负债/折扣）*折扣-利息  -负债 
	 * 
	 * 
	 */
	@Override
	public void invoke(TbSlPlatformUser user,  TbCatchdataStrategy ca,TbSlLoanStatTotal total) throws Exception {

		//long money = WebServiceUtils.getTotalNotPayback(user.getIdOfTbMerchantUser());
		//a0.getAlipayCheckException().setAmountInArrear(money);
		
		//String lasttime = WebServiceUtils.getPaymentLastcreateDate(user.getId(), TbSlSupplyPayment.COMPLETEPAY);
		
		long inveInMoney =  WebServiceUtils.getSupplyInventoryMoneyByplateformId(user.getId(),ca, null, null, TbSlSupplyInventory.IN);
		
		long inveOutMoney =  WebServiceUtils.getSupplyInventoryMoneyByplateformId(user.getId(),ca, null, null, TbSlSupplyInventory.OUT);

		//long unpay = money*100/Long.valueOf(user.getDiscount());
		total.setTotalUnsettleInstoreorder(Long.valueOf(inveInMoney));
		total.setTotalUnenterinRefundorder(Long.valueOf(inveOutMoney));
		
		
       // total.setTotalUnpaySettleorder(unpay);
        
		LogUtils.info(
				log,
				"[all store in inveInMoney:%s ] + [all store out--- inveOutMoney : %s]",
				user.getUsername(), inveInMoney, inveOutMoney);
		
	}

}
